/**
 * Copyright 2009 Sergio Bossa
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package com.googlecode.actorom.dsl.chain.messaging;

import com.googlecode.actorom.Address;
import com.googlecode.actorom.Topology;
import net.jcip.annotations.ThreadSafe;

/**
 * @author Sergio Bossa
 */
@ThreadSafe
public final class MethodExecutionBuilder {

    private final Topology topology;

    public MethodExecutionBuilder(Topology topology) {
        this.topology = topology;
    }

    /**
     * Set the {@link com.googlecode.actorom.Address} of the actor whose handler has to be swapped.
     */
    public SwapHandlerExecutor swap(Address address) {
        return new SwapHandlerExecutor(topology, address);
    }

    /**
     * Set the message object to send.
     */
    public SendMethodExecutor send(Object message) {
        return new SendMethodExecutor(topology, message);
    }

    /**
     * Set the source actor {@link com.googlecode.actorom.Address} to link from.
     */
    public LinkMethodExecutor link(Address fromAddress) {
        return new LinkMethodExecutor(topology, fromAddress);
    }

    /**
     * Set the source actor {@link com.googlecode.actorom.Address} to unlink.
     */
    public UnlinkMethodExecutor unlink(Address sourceAddress) {
        return new UnlinkMethodExecutor(topology, sourceAddress);
    }
}
